package com.itshidu.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.itshidu.lock.RedisLock;
import com.itshidu.lock.annotation.Lock;
import com.itshidu.lock.annotation.LockParam;
import com.itshidu.service.MyService;
import com.itshidu.web.tools.R;

@CrossOrigin(origins = "*")
@RestController
public class MyController {
	
	@Autowired RedisLock rlock;
	@Autowired MyService myService;
	
	@Lock
	@RequestMapping("/index")
	public Object index(@LockParam String key) throws InterruptedException {

		myService.hello();
		myService.hello();
		myService.hello();
		//Thread.sleep(3000);

		System.out.println("over");
		
		return R.of(1, "SUCCESS");
	}
	
}
